package cn.yanxiaohui.service.web.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.yanxiaohui.common.exception.APIException;
import cn.yanxiaohui.common.exception.APIExceptionErrorCode.BizError;
import cn.yanxiaohui.common.service.BaseService;
import cn.yanxiaohui.data.entity.BookMark;
import cn.yanxiaohui.data.mapper.BookMarkMapper;

/**
 * 书签业务层
 * @author yanxh
 *
 */
@Service
public class BookMarkService extends BaseService<BookMarkMapper,BookMark>{
	
	@Autowired
	BookMarkMapper bookMarkMapper;
	
	public List<BookMark> listByParams(Map<String, Object> params) {
		return bookMarkMapper.listByParams(params);
	}

	public BookMark getBookMarkDetailById(Long bookMarkId) throws APIException{
		BookMark bookMark = bookMarkMapper.selectByPrimaryKey(bookMarkId);
		if(bookMark == null) {
			throw new APIException(BizError.RESULT_IS_NULL.getCode(),
					BizError.RESULT_IS_NULL.getMessage()+"，数据ID为【"+bookMarkId+"】");
		}
		return bookMark;
	}

	public BookMark bookMarkById(Long id) {
		return bookMarkMapper.selectByPrimaryKey(id);
	}
	
}
